﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RioStudio.Website.Model;

namespace RioStudio.Website.View
{
    public partial class About : RioPage
    {
        private void GetData()
        {
            var model = tData.Instance.ExecuteReader<RioStudio.Website.Model.About>("Proc_GetAbout").FirstOrDefault();

            if (model != null)
            {
                lblFullname.Text = model.Fullname;
                lnkEmail.Text = model.Email;
                lnkEmail.NavigateUrl = "mailto:" + model.Email;
                lblJobTitle.Text = model.JobTitle;
                lblNickYahoo.Text = model.NickYahoo;
                lblPhone.Text = model.Phone;
                lblUniversity.Text = model.University;
                lblGender.Text = model.Gender ? "Nam" : "Nữ";
                lblBirthdate.Text = model.Birthdate.Date.ToShortDateString();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetData();

                rlvSocial.Rebind();
            }
        }

        protected void rlvSocial_NeedDataSource(object sender, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e)
        {
            try
            {
                rlvSocial.DataSource = tData.Instance.ExecuteReader<Social>("Proc_GetAllSocialNetworkByInactive", false).Where(i => i.DisplayInAbout == true);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}